package com.xc.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xc.demo.common.Result;
import com.xc.demo.entity.Customer;
import com.xc.demo.entity.Employee;
import com.xc.demo.entity.Orders;
import com.xc.demo.mapper.CustomerMapper;
import com.xc.demo.mapper.EmployeeMapper;
import com.xc.demo.mapper.OrdersMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/echarts")
public class EchartsController {


    @Resource
    private EmployeeMapper employeeMapper;

    @Resource
    private CustomerMapper customerMapper;

    @Resource
    private OrdersMapper ordersMapper;

    @GetMapping("/backend")
    public Result getBackCount(){

        QueryWrapper<Employee> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role","ROLE_SELLER");
     Integer backCount  = employeeMapper.selectCount(queryWrapper);
//     log.info(String.valueOf(backCount));

     return Result.success(backCount);

    }

    @GetMapping("/font")
    public Result getFontCount(){
        QueryWrapper<Customer> queryWrapper2 = new QueryWrapper<>();
        queryWrapper2.eq("status",1);
        Integer FontCount = customerMapper.selectCount(queryWrapper2);

        return Result.success(FontCount);
    }


    @GetMapping("/orders")
    public Result getOrdersCount(){
        QueryWrapper<Orders> queryWrapper3 = new QueryWrapper<>();
        queryWrapper3.like("no","2022");
        Integer OrdersCount = ordersMapper.selectCount(queryWrapper3);

        return Result.success(OrdersCount);
    }




}
